package com.newsReader.article.api;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.game.hall.model.WXGameUser;
import com.jfinal.core.Controller;
import com.newsReader.article.model.Article;
import com.newsReader.article.model.User;
import com.newsReader.category.model.Category;

public class ArticleApi extends Controller{

	/**
	 * 指定路径,route里的url+/getModel 获取用户Model
	 * @return 
	 */
	public void query(){
		String id = getPara("id");
		Map<String, Object> map = new HashMap<String,Object>();
		List<Article> Articlelist = Article.dao.ArticleList(Integer.valueOf(id));
		map.put("Articlelist", Articlelist);
	    renderJson(Articlelist);
	}
	
	/**
	 * 订阅列表
	 * @return 
	 */
	public void OrderArticleList(){
		String nickName = (String)getSession().getAttribute("nickName");
		List<User> users = User.dao.UserDetail(nickName);
	   // String userId = String.valueOf( users.get(0).get("id"));
		List<Article> Articlelist = Article.dao.OrderArticleList();
		renderJson(Articlelist);
	}
	
	/**
	 * 订阅详情
	 * @return 
	 */
	public void ArticleDetail(){
		String id = getPara("id");
		Article ArticleDetail = Article.dao.ArticleDetail(Integer.valueOf(id));
		renderJson(ArticleDetail);
	}
	//订阅列表详情
	public void OrderArticleDetailList(){
		String caid = getPara("caid");
		Map<String, Object> map = new HashMap<String,Object>();
		List<Article> Articlelist = Article.dao.OrderArticleDetailList(Integer.valueOf(caid));
		Category columnMap = Category.dao.columnDetail(Integer.valueOf(caid));
		map.put("columnMap", columnMap);
		map.put("Articlelist", Articlelist);
		renderJson(map);
	}
	
	
}